<template>
  <div class="my">



<!-- 用户信息 -->
   <navigator :url="tourl" >
	<view class="user-info">
			
		<image class="u-img" @click="prlimg"  :src="userinfo.default_img"></image>
	<view class="u-text">
		<view class="username">{{userinfo.name}}</view>
		<view class="small-text">
			欢迎使用,{{userinfo.name}}
		</view>
	</view>
	<view class="u-icon-setting" @click="toUserInfo">
		<u-icon name="arrow-right" color="rgb(227 227 227)" size="18"></u-icon>
	</view>
	
</view>
   </navigator>

  
  </div>
  <!-- 功能表单 -->
  <view>
  <view class="u-menu-list">
			<view class="u-menu-item" @click="itemClick(item)" v-for="(item,index) in menu" :key="index">
				<view class="u-menu-icon">
					<image class="fimage" :style="index==1?'width:35rpx;height: 35rpx;margin:0 10rpx;':'width:55rpx;height: 55rpx;'" :src="item.icon"></image>
				</view>
				<view class="u-menu-text">{{item.name}}</view>
				<view class="u-menu-icon-rigth">
					<u-icon name="arrow-right" color="rgb(231 231 231)" size="15"></u-icon>
				</view>
			</view>
		</view>
  </view>
  
  <view class="btitle">
	——关于我们——
  </view>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import {http} from '@/utlis/http'
import {useMemberStore} from "@/stores/modules/member.ts"
import { onShow } from '@dcloudio/uni-app'
const tourl=ref('/pages/login/login')
 // 4. 添加 token 请求头标识
 const memberStore = useMemberStore()
    var token = memberStore.profile
    if (token) {
      
    }
	else{
		token=''
	}

const userinfo=ref({
	name:'未登录',
	default_img:'/static/logo.png'
})


onShow(()=>{
	console.log('loadgff',memberStore.userinfo)
	
	if(memberStore.profile&&userinfo.value.name=='未登录'){
	
		uni.request({
	url: 'userinfo/',
	method: 'GET',
	
	success: ({ data, statusCode, header }) => {
		if(data['code']==200){
			userinfo.value=data['info']
			tourl.value='/pages/setting/setting'
		console.log('data',data['info'])
		memberStore.setuserinfo(data['info'])
		console.log('fff',memberStore.userinfo.default_img)
		}
	},
	fail: (error) => {
		uni.showToast({
			title: '网络错误',
			icon: 'error',
			mask: true
		})
	}
})

	}
	else{
	
	}
})


const menu=ref([
					{
						name: "我的订单",
						path: '/pages/order_list/order_list',
						icon: '/static/oder_front.png',
						color: ''
					},
					{
						name: "我的帖子",
						path: '/pages/personal/personal?user_id=""',
						icon: '/static/invitation.png',
						color: ''
					},
					{
						name: "我的评论",
						path: '/pages/mycomments/mycomments',
						icon: '/static/comment.png',
						color: ''
					},
					{
						name: "修改密码",
					
						icon: '/static/input.png',
						color: '',
						path: "/pages/password/password"
					},
					{
						name: "退出登录",
						path: '/pages/login/login',
						icon: '/static/delete.png',
						color: ''
					},
					// {
					// 	name: "系统设置",
					// 	path: '',
					// 	icon: '/static/setting.png',
					// 	color: ''
					// },
					
				])
const prlimg=(e)=>{
	console.log(e)
}

const itemClick=(item)=>{
if(item.name=='退出登录'){
	// #ifdef MP-WEIXIN
	memberStore.clearProfile()
	token=''
	tourl.value='/pages/login/login'
	userinfo.value={
	name:'未登录',
	default_img:'/static/logo.png'
	
}
// #endif
// #ifdef H5
uni.request({
		url: 'logout/',
		// data: {},
		header: {
			Accept: 'application/json',
			'Content-Type': 'application/json',
			'X-Requested-With': 'XMLHttpRequest'
		},
		method: 'DELETE',
		sslVerify: true,
		success: ({ data, statusCode, header }) => {
			console.log('logout:',data)
		},
		fail: (error) => {}
	})
	// #endif
}
console.log('item:',item)
uni.navigateTo({ url: item.path })
}

</script>
<style lang="scss">
.btitle{
	

	
	margin-top: 230rpx;
	width: 100%;
	font-size: 15px;
	color: rgba(0,0,0,0.4);
	text-align: center;
}
.user-info {
		 height: 200rpx;
		display: flex;
		align-items: center;
		padding: 150rpx 40rpx 60rpx 60rpx;
		background-image: linear-gradient(0deg, #24edc2, #befcef 90%);
		/* background-image: linear-gradient(135deg, #26bcff 10%, #078ef9); */

		/* #24edc2 */
		position: relative;

		.u-img {
			width: 150rpx;
			height: 150rpx;
			object-fit: cover;
			border-radius: 50%;
			border: 2rpx solid #FFFFFF;
		}

		.u-text {
			flex: 1;
			color: #FFFFFF;
			padding: 26rpx 30rpx;
		}

		.username {
			font-weight: bolder;
			font-family: 黑体;
		}

		.small-text {
			font-size: 24rpx;
			padding-top: 10rpx;
		}

		.u-icon-setting {
			width: 30rpx;
			color: #FFFFFF;
		}
	}

  .u-menu-list {
		background: #FFFFFF;
		margin: 0rpx;
		border-radius: 5rpx;
		border: 1px solid #f7f7f7;

		.u-menu-item {
			display: flex;
			padding: 30rpx 20rpx;
			border-bottom: 1px solid #f7f7f7;
			align-items: center;

			.u-menu-icon {
				padding-top: 8rpx;
				padding-right: 20rpx;
			}

			.u-menu-text {
				flex: 1;
				color: #5e5e5e;
			}

			.u-menu-icon-rigth {
				width: 30rpx;
			}
		}
	}
.fimage:nth-child(1){
	width: 40rpx;
	height: 40rpx;
}
</style>
